/**
 * 项目配置文件
 * 统一管理 API 地址和常量
 */

// 根据环境切换 API 地址

export const BASE_URL = 'http://localhost:8080';

// API 接口路径
export const API = {
  // 用户认证
  LOGIN: `${BASE_URL}/user/login`,
  REGISTER: `${BASE_URL}/user/register`,
  LOGOUT: `${BASE_URL}/user/logout`,
  SEND_CODE: `${BASE_URL}/sms/send/message`,
  RESET_PASSWORD: `${BASE_URL}/user/reset-password`,
  
  // 用户信息
  USER_PROFILE: `${BASE_URL}/user/users/profile`,
  USER_BY_PHONE: `${BASE_URL}/user/getCustomerIdByPhone`,

  // 统计
  USER_STATS: `${BASE_URL}/user/users/{customerId}/stats`,

  // 优惠券(?)
  USER_COUPONS: `${BASE_URL}/user/coupons/customer/{customerId}`,
  COUPON_BY_STATUS: `${BASE_URL}/user/coupons/customer/{customerId}/status/{status}`,
  COUPON_DETAIL: `${BASE_URL}/user/coupons/{couponId}`,
  COUPON_USE: `${BASE_URL}/user/coupons/use`,
  COUPON_REDEEM: `${BASE_URL}/user/coupons/customer/{customerId}/redeem`,
  COUPON_AVAILABLE: `${BASE_URL}/user/coupons/customer/{customerId}/available`,
  
  // 地址管理
  USER_ADDRESSES: `${BASE_URL}/user/addresses/customer`,
  ADDRESS_DETAIL: `${BASE_URL}/user/addresses/customer/{customerId}/address/{addressId}`,
  
  // 收藏管理
  USER_FAVORITES: `${BASE_URL}/user/favorites/customer`,
  FAVORITE_DETAIL: `${BASE_URL}/user/favorites/customer/{customerId}/product/{productId}`,
  
  // 钱包
  USER_WALLET: `${BASE_URL}/user/account/customer/{customerId}`,
  WALLET_LOG: `${BASE_URL}/user/log/customer/{customerId}/wallet/{walletId}`,
  
  // 愿望清单
  WISHLIST: `${BASE_URL}/user/wishlists`,
  WISHLIST_BY_REGION: `${BASE_URL}/user/wishlists/region/{regionId}`,
  WISHLIST_ADD: `${BASE_URL}/user/wishlists/add/{regionId}/{customerId}`,

  // 商家
  MERCHANT_DETAIL: `${BASE_URL}/user/merchants/nearby/detail/{merchantId}`,
  MERCHANT_BY_REGION: `${BASE_URL}/user/merchants/nearby/by-region/{regionId}`,
  MERCHANT_BY_TYPE: `${BASE_URL}/user/merchants/nearby/by-region/{regionId}/type/{type}`,
  MERCHANT_CATEGORIES: `${BASE_URL}/user/merchants/nearby/detail/{merchantId}/categories`,
  MERCHANT_PRODUCTS: `${BASE_URL}/user/merchants/nearby/detail/{merchantId}/category/{categoryId}/products`,
  CURRENT_REGION: `${BASE_URL}/user/merchants/nearby/get-regionId/by-current`,

  // 商品
  PRODUCT_DETAIL: `${BASE_URL}/user/merchants/nearby/product/{productId}/detail`,
  
  // 订单
  ORDER_SUBMIT: `${BASE_URL}/user/orders/add/order`,
  ORDER_BY_USER: `${BASE_URL}/user/orders/by-user/{customerId}`,
  ORDER_BY_STATUS: `${BASE_URL}/user/orders/by-status/{customerId}/{status}`,
  ORDER_DETAIL: `${BASE_URL}/user/orders/order/detail/{orderId}`,
  ORDER_PAY: `${BASE_URL}/user/orders/{orderId}/pay`,
  ORDER_REVIEW: `${BASE_URL}/user/orders/order/review/{orderId}`,
  
  // 评价
  REVIEW_BY_MERCHANT: `${BASE_URL}/user/reviews/listByMerchant`,
  REVIEW_BY_ORDER: `${BASE_URL}/user/reviews/listByOrder`,
  REVIEW_DETAIL: `${BASE_URL}/user/reviews/{reviewId}`,
  REVIEW_REPLIES: `${BASE_URL}/user/reviews/{reviewId}/replies`,
  REVIEW_REPLY: `${BASE_URL}/user/reviews/{reviewId}/reply`,
  REVIEW_ADD: `${BASE_URL}/user/reviews`,

  // 消息中心
  MESSAGE_NOTIFICATIONS: `${BASE_URL}/user/messages/notifications`,
  MESSAGE_SESSIONS: `${BASE_URL}/user/messages/sessions`,
  MESSAGE_HISTORY: `${BASE_URL}/user/messages/sessions/{sessionId}/history`,
  MESSAGE_SEND: `${BASE_URL}/user/messages/sessions/{sessionId}/messages`,
  MESSAGE_MARK_READ: `${BASE_URL}/user/messages/sessions/{sessionId}/mark-read`,
  MESSAGE_DELETE_SESSION: `${BASE_URL}/user/messages/sessions/{sessionId}`,
  MESSAGE_UNREAD_COUNT: `${BASE_URL}/user/messages/unread-count`,

  // 投诉
  COMPLAINT_MY_LIST: `${BASE_URL}/user/complaints/myComplaints/{customerId}`,
  COMPLAINT_DETAIL: `${BASE_URL}/user/complaints/{customerId}/complaint/detail/{complaintId}`,
  COMPLAINT_SUBMIT: `${BASE_URL}/user/complaints/{customerId}/submit`,
  COMPLAINT_CANCEL: `${BASE_URL}/user/complaints/{customerId}/cancel/{complaintId}`,
};


// 常量配置
export const CONSTANTS = {
  // 验证码倒计时(秒)
  CODE_COUNTDOWN: 60,
  
  // 默认头像
  DEFAULT_AVATAR: '/static/logo.png',
  
  // 分页大小
  PAGE_SIZE: 10,

  // 订单状态
  ORDER_STATUS: {
    UNPAID: 0,        // 待支付
    PAID: 1,          // 已支付
    PREPARING: 2,     // 备餐中
    DELIVERING: 3,    // 配送中
    COMPLETED: 4,     // 已完成
    CANCELLED: 5,     // 已取消
  },

  // 投诉类型
  COMPLAINT_TYPE: {
    PRODUCT_DAMAGE: 1,    // 商品破损
    DELIVERY_TIMEOUT: 2,  // 配送超时
    DELIVERY_DELAY: 3,    // 配送延迟
    OTHER: 4,             // 其他
  },

  // 投诉状态
  COMPLAINT_STATUS: {
    PENDING: 0,      // 待处理
    PROCESSING: 1,   // 处理中
    RESOLVED: 2,     // 已解决
    REJECTED: 3,     // 已拒绝
  },

  // 消息类型
  MESSAGE_TYPE: {
    TEXT: 1,         // 文本
    IMAGE: 2,        // 图片
    ORDER: 3,        // 订单消息
  },

  // 聊天类型
  CHAT_TYPE: {
    CUSTOMER_SERVICE: 1,  // 客服
    MERCHANT: 2,          // 商家
  },
};

// 缓存键名
export const STORAGE_KEY = {
  TOKEN: 'token',                    // 用户令牌
  USER_INFO: 'userInfo',            // 用户信息
  LOCATION: 'userLocation',          // 用户位置
  SEARCH_HISTORY: 'searchHistory',   // 搜索历史
  CART: 'cart',                      // 购物车
};